<?php
/**
 * Pes for PHP 5.3+
 *
 * Copyright (c) 2013 phpeskill.com (http://www.phperskill.com)
 *
 * For the full copyright and license information, please view
 * the file LICENSE.md that was distributed with this source code.
 */
namespace Model;
use \Core\Model\Model as Model;
use Core\Db\Db as Db;

/**
 * PES程序主公共模块
 * @author LazyPHP
 * @version 1.0
 */
class AllModel extends Model {

    /**
     * 初始化数据库
     * @param str $name 表名
     * @return obj 返回数据库对象
     */
    protected static function db($name){
        $db = Db::__init();
        $db->tableName($name);
        return $db;
    }
    
    /**
     * 获取表内容
     * @param type $value 查找值
     * @param type $type 查找类型
     * @param type $table 表名
     * @return boolean
     */
    protected static function GetTableContent($value="", $type="", $table){
        $db = self::db($table);
        if(empty($value)){
            $result = $db->select();
            return $result;
        }else{
            $data[$type] = $value;
            $result = $db->where("{$type} = :{$type}")->find($data);
            if(empty($result)){
                return false;
            }
            return $result;
        }
    }
}
